<template>
    <view class="container data-v-ce0de7e8" v-if="info">
        <coupon-item @__l="__l" class="data-v-ce0de7e8" :coupon="info" vueId="b86be15a-1"></coupon-item>
        <view @tap="__e" class="check-user-group-btn data-v-ce0de7e8" :data-event-opts="[['tap', [['e0', ['$event']]]]]">查看领取条件</view>
        <block v-if="!info.is_picked">
            <button @tap="__e" class="pick-btn global-shadow data-v-ce0de7e8" :data-event-opts="[['tap', [['useCode', ['$event']]]]]" hoverClass="hover" v-if="code">
                确认兑换
            </button>
            <block v-else>
                <view @tap="__e" class="yhq-btn data-v-ce0de7e8" :data-event-opts="[['tap', [['pickCoupon', ['$event']]]]]" v-if="!info.score_price">领取优惠券</view>
                <view @tap="__e" class="yhq-btn data-v-ce0de7e8" :data-event-opts="[['tap', [['pickCouponWithScore', ['$event']]]]]" v-else>
                    {{ '使用' + info.score_price + scoreAlias + '兑换' }}
                </view>
            </block>
        </block>
        <view @tap="__e" class="yhq-btn data-v-ce0de7e8" :data-event-opts="[['tap', [['toUse', ['$event']]]]]" v-else>已领券，去使用</view>
        <user-group-check
            @__l="__l($event, { eventOpts: [['^close', [['e1']]]] })"
            @close="__e($event, { eventOpts: [['^close', [['e1']]]] })"
            class="data-v-ce0de7e8"
            :data-event-opts="[['^close', [['e1']]]]"
            title="领取此券"
            :userGroupId="info.user_group_id"
            vueId="b86be15a-2"
            v-if="isShowUserGroupCheck"
        ></user-group-check>
    </view>
</template>

<script>
import userGroupCheck from '@/components/UserGroupCheck/UserGroupCheck';
import iButton from '@/components/Button/index';
import couponItem from '@/pages/couponDetail/components/CouponItem';
import tabBar from '@/components/TabBar/tabBar';
(global.webpackJsonp = global.webpackJsonp || []).push([
    ['pages/couponDetail/index'],
    {
        '45e5': function (n, t, o) {},
        '57c8': function (n, t, o) {
            'use strict';

            o.d(t, 'b', function () {
                return i;
            });
            o.d(t, 'c', function () {
                return c;
            });
            o.d(t, 'a', function () {
                return e;
            });
            var e = {
                UserGroupCheck: function () {
                    return o.e('components/UserGroupCheck/UserGroupCheck').then(o.bind(null, 'add4'));
                }
            };
            var i = function () {
                var that = this;
                that.$createElement;
                that._self._c;
                that._isMounted ||
                    ((that.e0 = function (t) {
                        that.isShowUserGroupCheck = true;
                    }),
                    (that.e1 = function (t) {
                        that.isShowUserGroupCheck = false;
                    }));
            };
            var c = [];
        },
        '6da6': function (n, t, o) {
            'use strict';

            o.r(t);
            var e = o('9f27');
            var i = o.n(e);
            for (var c in e) {
                if (['default'].indexOf(c) < 0) {
                    (function (n) {
                        o.d(t, n, function () {
                            return e[n];
                        });
                    })(c);
                }
            }
            t.default = i.a;
        },
        '9eb4': function (n, t, o) {
            'use strict';

            (function (n, t) {
                var e = o('4ea4');
                o('18ba');
                e(o('66fd'));
                var i = e(o('e9dd'));
                n.__webpack_require_UNI_MP_PLUGIN__ = o;
                t(i.default);
            }.call(this, o('bc2e').default, o('543d').createPage));
        },
        '9f27': function (n, t, o) {
            'use strict';

            (function (n) {
                var e = o('4ea4');
                Object.defineProperty(t, '__esModule', {
                    value: true
                });
                t.default = void 0;
                var i = {
                    mixins: [e(o('452d')).default],
                    components: {
                        IButton: function () {
                            o.e('components/Button/index')
                                .then(
                                    function () {
                                        return resolve(o('93c4'));
                                    }.bind(null, o)
                                )
                                .catch(o.oe);
                        },
                        CouponItem: function () {
                            o.e('pages/couponDetail/components/CouponItem')
                                .then(
                                    function () {
                                        return resolve(o('552a'));
                                    }.bind(null, o)
                                )
                                .catch(o.oe);
                        }
                    },
                    data: function () {
                        return {
                            uuid: '',
                            info: {},
                            code: '',
                            isShowUserGroupCheck: false
                        };
                    },
                    filters: {},
                    onLoad: function (n) {
                        this.uuid = n.uuid;
                        this.code = n.code || '';
                        this.initData();
                        this.$visitor.record('couponn_detail');
                    },
                    onShow: function () {
                        this.initData();
                    },
                    methods: {
                        useCode: function () {
                            var that = this;
                            n.showLoading({
                                title: '兑换中'
                            });
                            this.$http('/code/use', 'POST', {
                                code: this.code
                            }).then(function (o) {
                                n.hideLoading();
                                n.showToast({
                                    title: '兑换成功',
                                    icon: 'none'
                                });
                                that.initData();
                            });
                        },
                        toUse: function () {
                            if (this.info.to_use_link && 'none' != this.info.to_use_link.type) {
                                this.toLink(this.info.to_use_link);
                            } else {
                                n.switchTab({
                                    url: '/pages/shop/index'
                                });
                            }
                        },
                        initData: function () {
                            var that = this;
                            this.$api.emit('core.coupon.show', this.uuid).then(function (o) {
                                that.info = o.data.info;
                                console.log(o.data);
                                that.info.is_shareable || n.hideShareMenu();
                            });
                        },
                        pickCoupon: function () {
                            var that = this;
                            n.showLoading({
                                title: '领取中',
                                mask: false
                            });
                            this.$api
                                .emit('core.coupon.pick', this.uuid)
                                .then(function (o) {
                                    n.hideLoading();
                                    that.initData();
                                    n.showToast({
                                        title: '领取成功',
                                        icon: 'none'
                                    });
                                })
                                .catch(function (n) {});
                        },
                        pickCouponWithScore: function () {
                            var that = this;
                            n.showModal({
                                title: '兑换提示',
                                content: '确认支付' + this.info.score_price + this.scoreAlias + '兑换此优惠券吗?',
                                success: function (n) {
                                    if (n.confirm) {
                                        that.pickCoupon();
                                    }
                                }
                            });
                        }
                    }
                };
                t.default = i;
            }.call(this, o('543d').default));
        },
        cb69: function (n, t, o) {
            'use strict';

            var e = o('45e5');
            o.n(e).a;
        },
        e9dd: function (n, t, o) {
            'use strict';

            o.r(t);
            var e = o('57c8');
            var i = o('6da6');
            for (var c in i) {
                if (['default'].indexOf(c) < 0) {
                    (function (n) {
                        o.d(t, n, function () {
                            return i[n];
                        });
                    })(c);
                }
            }
            o('cb69');
            var u = o('f0c5');
            var a = Object(u.a)(i.default, e.b, e.c, false, null, 'ce0de7e8', null, false, e.a, void 0);
            t.default = a.exports;
        }
    },
    [['9eb4', 'common/runtime', 'common/vendor']]
]);
</script>
<style>
@import './index.css';
</style>
